package com.lcf.app.oauth2.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import sun.security.provider.PolicyParser;

/**
 * 授权服务器配置
 */
@Configuration
@EnableAuthorizationServer
public class AuthServerConfig extends AuthorizationServerConfigurerAdapter {

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory()
                //client-id
                .withClient("admin")
                //client-secret
                .secret("admin")
                //权限范围
                .scopes("all")
                //授权模式:密码("password")，授权码模式("authorization_code")
                .authorizedGrantTypes("authorization_code")
                //accessToken过期时间
                .accessTokenValiditySeconds(60 * 60 * 30)
                //refreshToken过期时间
                .refreshTokenValiditySeconds(60 * 60 * 30)
                //授权成功后重定向地址
                .redirectUris("http://www.baidu.com");
    }
}
